# -*- coding: utf-8 -*-
# @Time    : 2022/7/22 23:33
# @Author  : xhf
# @Email   : xhf9309@163.com
# @File    : commodity_details.py
# @Software: PyCharm
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class CommodityDetailsPage(BasePage):
    '''商品详情页类'''
    '''定位器'''
    service_locator = (By.XPATH,'//android.view.View[@text=\"客服\"]')    #客服定位器
    home_page_locator = (By.XPATH,'//android.view.View[@text=\"首页\"]')  #首页定位器
    shopping_trolley_locator = (By.XPATH,'//android.view.View[@text=\"购物车\"]')  #购物车定位器
    canel_locator = (By.ID,'com.gfeng.daydaycook:id/cancel_textview')   #客服页面的取消定位器



    def ele_click_service(self, x=40, y=1540):
        '''点击客服'''
        self.driver.tap([(x,y)])

    def ele_click_home_page(self, x=115, y=1540):
        '''点击首页'''
        self.driver.tap([(x,y)])

    def ele_click_shopping_trolley(self, x=175,y=1540):
        '''点击购物车'''
        self.driver.tap([(x,y)])

    def assert_cancel(self):
        '''获取客服页面取消按钮的文本'''
        return self.find_element(self.canel_locator).text

    def assert_shopping_trolley(self,x=450, y=90):
        '''获取购物车标题坐标'''
        return self.driver.tap([(x,y)]).text

    def func_click_service(self):
        '''聚合-点击客户'''
        self.ele_click_service()

    def func_click_homepage(self):
        '''聚合-点击首页'''
        self.ele_click_home_page()

    def func_click_shopping_trolley(self):
        '''聚合-点击购物车'''
        self.ele_click_shopping_trolley()